﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class AttackObjectTempVector
{

    private List<ActiveObject> attackTempVector;

    public AttackObjectTempVector(List<ActiveObject> objs)
    {

        if (objs.Count > 0)
            attackTempVector = objs;
    }


    public void sendHitLimit(int count,ActiveObject attacker, float damage, DamageBounsType type, params float[] vector)
    {

        if (attackTempVector != null && attackTempVector.Count > 0)
        {

            int maxIndex = Mathf.Min(count, attackTempVector.Count);

            for (int indexObj = 0; indexObj < maxIndex; indexObj++)
            {
                ActiveObject i = attackTempVector[indexObj];
                i?.sendHit(attacker, damage, type, vector);
            }
        }
    }

    public bool sendHit(ActiveObject attacker, float damage, DamageBounsType type, params float[] vector)
    {
        bool flag = false;

        if (attackTempVector != null && attackTempVector.Count > 0)
        {
            foreach (ActiveObject i in attackTempVector)
            {
                i?.sendHit(attacker, damage, type, vector);
                if (!flag)
                    flag = true;
            }
            
        }
        return flag;
    }

}

